local chezheng = fk.CreateSkill {
  name = "mini__chezheng",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable{
  ["mini__chezheng"] = "掣政",
  [":mini__chezheng"] = "锁定技，你的出牌阶段内，攻击范围内不包含你的其他角色不能成为你使用牌的目标。"..
  "出牌阶段结束时，你摸等同于这些角色数的牌，然后弃置其中一名角色一张牌。",

  ["#mini__chezheng-throw"] = "掣政：弃置其中一名角色一张牌",

  ["$mini__chezheng1"] = "朕倒要看看，这大吴是谁的江山！",
  ["$mini__chezheng2"] = "只要朕还在，老贼休想稳坐一天！",
}

chezheng:addEffect(fk.EventPhaseEnd, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(chezheng.name) and player.phase == Player.Play and
      table.find(player.room:getOtherPlayers(player, false), function(p)
        return not p:inMyAttackRange(player)
      end)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room:getOtherPlayers(player, false), function(p)
      return not p:inMyAttackRange(player)
    end)
    player:drawCards(#targets, chezheng.name)
    if player.dead then return end
    targets = table.filter(targets, function(p)
      return not p:isNude()
    end)
    if #targets > 0 then
      local to = room:askToChoosePlayers(player, {
        min_num = 1,
        max_num = 1,
        targets = targets,
        skill_name = chezheng.name,
        prompt = "#mini__chezheng-throw",
        cancelable = false,
      })[1]
      local card = room:askToChooseCard(player, {
        target = to,
        flag = "he",
        skill_name = chezheng.name,
      })
      room:throwCard(card, chezheng.name, to, player)
    end
  end,
})

chezheng:addEffect("prohibit", {
  is_prohibited = function (self, from, to, card)
    return from and from:hasSkill(chezheng.name) and card and from.phase == Player.Play and
      from ~= to and not to:inMyAttackRange(from)
  end,
})

return chezheng
